#if !defined(SM__DISPLAY_H)
#define SM__DISPLAY_H

// NOTE: We'll refactor this later as the code becomes more organized
// for now this is just my playground for SDL_ttf, but I envision this one day 
// as a Display class that handles all initialization, painting, updating, etc 
// including the stuff that's currently done within main() and DrawScene()

#include <map>
#include <string>
#include "SDL.h"
#include "SDL_ttf.h"

void Slock(SDL_Surface *screen);
void Sulock(SDL_Surface *screen);
// this is also at http://www.libsdl.org/intro.en/usingvideo.html
void DrawPixel(SDL_Surface *screen, int x, int y, Uint8 R, Uint8 G, Uint8 B);

// Display manager class, manages fonts, holds a reference
// to the screen surface, draws text on screen, locks/unlocks
// the screen surface
class Display {
  private:
    // this is the screen surface
    SDL_Surface* mpScreen;
    bool mbScreenLocked;

    // This is a cache of all fonts that are requested by the app
    // This is only closed/emptied when the Display is destroyed
    std::map<std::string, std::map<int, TTF_Font*> > mFontMap;
    TTF_Font* mpCurrentFont;
  public:
    Display();
    ~Display();

    void SetCurrentFont(const char* sFontFileName, int ptSize);
    TTF_Font* GetCurrentFont() const { return mpCurrentFont; }

    void DrawText(const char* szText, const SDL_Color& color, Sint16 _x, Sint16 _y) const;
    void DrawText(SDL_Surface* screen, const char* szText, const SDL_Color& color, Sint16 x, Sint16 y) const;

    SDL_Surface* getScreen() const { return mpScreen; }

    void LockScreen();
    void UnlockScreen();
    void Flip();
};

#endif // SM__DISPLAY_H
